package sg.edu.nus.iss.stockex;

public class StockCode implements Comparable<StockCode>{
	private String code;
	private String name;
	
	public StockCode()
	{
		
	}

	public StockCode(String code, String name) {
		super();
		this.code = code;
		this.name = name;
	}

	public static StockCode parseString(String stockStr)
	{
		StockCode stockCode = null;
		try
		{
			String[] stockData = stockStr.split(";");
			String code = stockData[0].trim();
			String name = stockData[1].trim();
			
			stockCode = new StockCode(code, name);
		}catch(Exception ex)
		{
			return null;
		}

		return stockCode;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Override
	public int compareTo(StockCode other) {
		return this.name.compareTo(other.name);
	}

}